<?xml version="1.0"?>
<!-- AutoNantTopLevel.xslt - Generate a Nant build file (top level)
   - Tamara Roberson <tamara.roberson@gmail.com>
   - v.0.0.2 (2007-02-11)
   - RELEASED IN THE PUBLIC DOMAIN
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
	<xsl:output method="xml" indent="yes" />

	<xsl:variable name="debug">true</xsl:variable>

	<!-- MAIN -->
	<xsl:template match="/autonant">
		<project name="{@name}" default="build" basedir=".">
			<!-- Description -->
			<description>
				<xsl:value-of select="description" />
			</description>

			<property
			  name="base.dir"
			  overwrite="false"
			  value="${{project::get-base-directory()}}" />

			<property
			  name="filename"
			  overwrite="false"
			  value="default.autonant" />

			<property
			  name="build.dir"
			  value="${{path::combine (base.dir, 'build')}}" />

			<property
			  name="autonant-buildfile"
			  value="${{build.dir}}/autonant/default.build" />
			  
			<property
			  name="buildfile"
			  value="${{filename}}.build" />

			<property
			  name="buildfile_path"
			  value="${{path::combine (build.dir, buildfile)}}" />

	  		<property name="has_externals">
				<xsl:attribute name="value">
					<xsl:choose>
						<xsl:when test="/autonant/externals">
								<xsl:text>true</xsl:text>
						</xsl:when>
						<xsl:otherwise>
								<xsl:text>false</xsl:text>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:attribute>
			</property>

			<property
			  name="boo_tasks"
			  value="/usr/local/lib/boo/Boo.NAnt.Tasks.dll" />

			<target name="autonant-build">
				<nant
				  target="build"
				  buildfile="${{autonant-buildfile}}" />
			</target>
			
			<target name="autonant-clean">
				<nant
				  target="clean"
				  buildfile="${{autonant-buildfile}}" />
			</target>

			<target name="build" depends="autonant-build">
				<nant
				  target="build"
				  buildfile="${{buildfile_path}}" />
			</target>

			<target name="clean" depends="autonant-build">
				<nant
				  target="clean"
				  buildfile="${{buildfile_path}}" />
				<call target="autonant-clean" />
			</target>
		</project>
	</xsl:template>
</xsl:stylesheet>

